To build an executable that uses a DSO, call a compiler driver just as you would for a non-shared library. For instance,
This command links the resulting object file (needle.o) with the previously built DSO libthread.so (and the standard C DSO, libc.so.1), if available. If no libthread.so exists, but a PIC archive named libthread.a exists, that archive is used with libc.so.1, so you still get dynamic (run time) linking. Note that even .a libraries now contain position-independent code by default, though it is also possible to build non-shared .a libraries that do not contain PIC.cc needle.c -lthread